package main

import (
	"context"
	"fmt"
	"github.com/redis/go-redis/v9"
	"mxshop_api/user-web/global"
	"mxshop_api/user-web/initialize"
)

func main() {
	initialize.InitConfig()
	fmt.Println(global.ServerConfig.RedisInfo.Password)
	sprintf := fmt.Sprintf("%s:%d", global.ServerConfig.RedisInfo.Host, global.ServerConfig.RedisInfo.Port)
	fmt.Println(sprintf)
	rdb := redis.NewClient(&redis.Options{
		Addr:     sprintf,
		Password: global.ServerConfig.RedisInfo.Password, // no password set
		DB:       global.ServerConfig.RedisInfo.Db,       // use default DB
	})

	err := rdb.Set(context.Background(), "key", "value", 0).Err()
	if err != nil {
		panic(err)
	}

	val, err := rdb.Get(context.Background(), "key").Result()
	if err != nil {
		panic(err)
	}
	fmt.Println("key", val)
}
